﻿/*
 *	Copyright (c) 2009 Queensland University of Technology. All rights reserved.
 *	The QUT Bioinformatics Collection is open source software released under the 
 *	Microsoft Public License (Ms-PL): http://www.microsoft.com/opensource/licenses.mspx.
 */
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using QUT.Bio.SilverMap;
using QUT.Bio.SilverMap.ObjectModel;
using QUT.Bio.Util;

namespace QUT.Bio.SilverMap.DefaultProvider {
	/// <summary>
	/// A DataProvider that loads data from the mquter silvermap web service.
	/// </summary>

	public class DataProducer: QUT.Bio.SilverMap.DataProvider {
		private readonly ObjectModel objectModel;
		private Loader loader;

		/// <summary>
		/// Initialise the DataProvider.
		/// </summary>
		/// <param name="overlay">A popup overlay used to display alerts and information messages to the user.</param>
		
		public DataProducer ( PopupOverlay overlay )
			: base( overlay ) {
			objectModel = new ObjectModel( overlay );
			objectModel.LoadComplete += delegate( IFeatureCollection ignored ) {
				SignalLoadComplete();
			};
		}

		override public QUT.Bio.SilverMap.ObjectModel.IFeatureCollection FeatureCollection {
			get {
				return objectModel;
			}
		}

		public override bool IsInteractive {
			get {
				return true;
			}
		}

		override public void DisplayLoadDialog () {
			if ( loader == null ) {
				loader = new Loader();
				loader.Init( objectModel, Overlay );
			}

			Overlay.ShowWindow( loader.Dialog,
				Overlay.ActualWidth * 0.125, Overlay.ActualHeight * 0.125,
				Overlay.ActualWidth * 0.75, Overlay.ActualHeight * 0.75
			);
		}

		override public string Name {
			get {
				return "Load (MQUTeR)";
			}
		}

		override public void Initialise ( QUT.Bio.Util.Arguments args ) {
			throw new NotImplementedException();
		}
	}
}
